const mongoose = require('mongoose')

const Schema = mongoose.Schema

const courseSchma = Schema({
  coursename: { // 课程名称
    type: String,
    required: true
  },
  description: { // 课程描述
    type: String,
    required: true
  },
  price: { // 课程价格
    type: String,
    required: true,
    default: '免费'
  },
  buyNum: { // 课程购买量
    type: Number,
    required: true,
    default: 0
  },
  type: {
    type: String,
    require: true
  },
  courseType: { // 课程分类
    type: String,
    required: true,
    default: '全部'
  },
  teacherId: { // 上传教师的账号
    type: String,
    required: true
  },
  teacherName: {
    type: String,
    required: false
  },
  evaluate: { // 课程评论
    type: Array,
    default: ([{
      evaluateAvatar: '',
      evaluateNickname: '',
      evaluateContent: '',
      score: 0
    }])
  },
  chatMsg: {
    type: Array,
    default: ([{
      nickname: '',
      ctime: '',
      chatContent: ''
    }])
  },
  courseURI: {
    type: String,
    required: true
  }
})

module.exports = mongoose.model('Course', courseSchma)